package com.amigo.online.provider.video.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import com.amigo.online.common.core.mybatis.MyMapper;
import com.amigo.online.common.param.result.promote.PromoteOrderDetailInfo;
import com.amigo.online.common.param.result.promote.PromoteOrderInfo;
import com.amigo.online.provider.video.model.entity.PromoteVideo;

@Mapper
@Component
public interface PromoteMapper extends MyMapper<PromoteVideo> {

    PromoteVideo getPromoteById(Long promoteId);

    List<PromoteOrderInfo> getPromoteByUserId(@Param("userId") Long userId, @Param("size") Integer size, @Param("offset") Integer offset);

    /**
     * 查询速推订单详情
     *
     * @param promoteId
     * @return
     */
    PromoteOrderDetailInfo getPromoteOrderDetail(Long promoteId);

    int updatePormoteVideoStatus(PromoteVideo promoteVideo);

    List<PromoteVideo> getPromoteVideo(@Param("videoIds") List<Long> videoIds,
                                       @Param("area_ids") Long area_ids, @Param("sex") String sex);

    @Update("update video_promote_tbl set play_amount = play_amount + 1, balance = balance - #{reduce} where id = #{id}")
    int increasePlayAmountById(@Param("id") Long id, @Param("reduce") Integer reduce);

    @Select("select user_id from video_promote_tbl where id = #{promoteId}")
    Long getPromoteUserId(Long promoteId);


}
